<html>
<head>
<title>Scenario 6.1</title>
</head>

<body>
<h3>Scenario 6.1</h3>

<p>
Like <a href="scenario-1p1a.html">1.1</a>,
but if and only if the entire set of examples is valid with
respect to Suite Foo, user wants to process each example one at a
time, doing the following for each example:
<pre>
       i. Update Discrimination definitions of Suite Foo,
       ii. Apply the model currently implicit in the training state of 
           Suite Foo to the examples to make predictions, THEN
       iii. Update training state of Suite Foo using this example
</pre>

<p><strong>Implementaion</strong>

<p>We use definitional parsing, since we want to update the
discrimination definitions.  The actual score-and-train loop is 
similar to what goes on inside Learner.absorbExample( Vector...).


<pre>
  import boxer.*;

  ...

  Suite suite = new Suite("foo.xml"); // create suite...
  // modify suite by any preceding definitional parsing etc
  ....                                
  // validate the set of examples from dataset XML
  // a "datapoint" element
  String f ="dataset.xml"; 
  org.w3c.dom.Element e = ParseXML.readFileToElement(f); 
  boolean isDefinitional = false;
  int n=ParseXML.validateDatasetElement(e, suite, isDefinitonal);
  if (n &gt; 0) {
        // parse the data against the main suite
        Vector <DataPoint> v = ParseXML.parseDatasetElement(e, suite, isDefinitional);
        // Score each one, and then train the learner on it.
        for(DataPoint p: v) {
          // Have the learner score the example. In the result array,
          // scores[i][j] will contain the learner-estimated probability 
          // of the example p's belonging to the j-th class of the i-th 
          // discrimination of the suite.
          double[][] scores = learner.applyModel(p);
          // Now, train the learner on the example
          learner.absorbExample(p);
        }

	System.out.println("[VALIDATE] The data set from file " + f + 
        " appears to be fully acceptable as a test set in the current "+
        "suite. It contains " + n + " data points, and we had the learner " +
        "score and then absord each one");
  } else {
	 System.out.println("[VALIDATE] It would not be possible to parse "+
         "the data set from file " + f + 
         " as a test set in the current suite. Please see a warning "+
         "message in the log for detals");
  }

</pre>	


<hr>

Back to <a href="standard-scenarios.html">All scenarios</a>

</body>
</html>
